package com.mall.shopping.converter;

import com.mall.shopping.dal.entitys.Panel;
import com.mall.shopping.dal.entitys.PanelContent;
import com.mall.shopping.dto.PanelContentItemDto;
import com.mall.shopping.dto.PanelDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;
import java.util.Set;

/**
 * xdx
 */
@Mapper(componentModel = "spring")
public interface PanelConvertor {

    /**
     * 如果不写@Mappings注解，能不能自动对应名称相同的成员变量？？？
     * @param panel
     * @return
     */
    @Mappings({
            @Mapping(source = "id",target = "id"),
            @Mapping(source = "name",target = "name"),
            @Mapping(source = "type",target = "type"),
            @Mapping(source = "sortOrder",target = "sortOrder"),
            @Mapping(source = "position",target = "position"),
            @Mapping(source = "limitNum",target = "limitNum"),
            @Mapping(source = "status",target = "status"),
            @Mapping(source = "remark",target = "remark")
    })
    PanelDto convert2DTO(Panel panel);



    Set<PanelDto> convert2DTOs(Set<Panel> panels);

    @Mappings({
            @Mapping(source = "id",target = "id"),
            @Mapping(source = "panelId",target = "panelId"),
            @Mapping(source = "type",target = "type"),
            @Mapping(source = "productId",target = "productId"),
            @Mapping(source = "sortOrder",target = "sortOrder"),
            @Mapping(source = "fullUrl",target = "fullUrl"),
            @Mapping(source = "picUrl",target = "picUrl"),
            @Mapping(source = "picUrl2",target = "picUrl2"),
            @Mapping(source = "picUrl3",target = "picUrl3"),
            @Mapping(source = "created",target = "created"),
            @Mapping(source = "updated",target = "updated")
    })
    PanelContentItemDto convert(PanelContent panelContent);

    List<PanelContentItemDto> convert(List<PanelContent> panelContent);

}
